home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pasmou.zip / DEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-06-14  |  3KB  |  75 lines

  1. (* This program demonstrates Dave Kirsch's 'true' EGA/VGA mouse routines. *)
  2. program Demo;
  3.  
  4. uses DOS, CRT, mouse;
  5.  
  6. var oldmx, oldmy: integer;
  7.  
  8. begin
  9.    M^.buttonstat := 0;
  10.    oldmx := -1;
  11.    oldmy := -1;
  12.    MOUinit;                         (* initialization *)
  13.    if mouseinstalled = 0 then
  14.       begin
  15.         WriteLn('Please install your mouse driver before running this test.');
  16.         halt;
  17.       end;
  18.  
  19.    MOUhide;                                (* hide the mouse cursor *)
  20.    ClrScr;
  21.    MOUmove(40,13);                         (* move the mouse cursor to the center of the screen *)
  22.    MOUconfine(10,0,70,20);                 (* confine the mouse cursor within these cooridinates *)
  23.    MOUShow;                                (* display the mouse cursor *)
  24.    GoToXY(1,8);
  25.    WriteLn('Turbo Pascal demo of Dave Kirsch''s ''true'' EGA/VGA');
  26.    WriteLn('C mouse cursor functions.  Pascal demo by Jim Loos.');
  27.    WriteLn;
  28.    WriteLn('Click here [■] with left mouse button to quit.');
  29.  
  30.    repeat
  31.       if (mousex <> oldmx) OR (mousey <> oldmy) then  (* if position has changed... *)
  32.          begin
  33.             oldmx := mousex;               (* mousex and mousey are the mouse cursor X and Y *)
  34.             oldmy := mousey;               (* corrdinates updated continuously by the driver *)
  35.             MOUconditionalhide(0,0,50,0);  (* hide the cursor if it happens to be on the top line *)
  36.             GoToXY(1,1);
  37.             write('Mouse position: ', mousex:2, '  ', mousey:2);
  38.             MOUshow;                       (* display the mouse cursor *)
  39.           end;
  40.  
  41.       if MOUcheck then                     (* if a mouse event is waiting in buffer... *)
  42.          begin
  43.             MOUget(M);                     (* 'M' is the pointer to the mouse information *)
  44.             MOUconditionalhide(0,3,32,5);  (* record.  Both 'M' and the record are declared *)
  45.             case M^.buttonstat of          (* in the MOUSE.TPU unit.  Field 'buttonstat' of *)
  46.                LEFTBPRESS:                 (* the record contains the status of the mouse buttons *)
  47.                   begin                    (* Fields 'cx' and 'cy' are the mouse cursor coordinates *)
  48.                      GoToXY(1,4);          (* when the event occured *)
  49.                      write('Left button pressed  at: ', M^.cx:2, ' ', M^.cy:2);
  50.                   end;
  51.                RIGHTBPRESS:
  52.                   begin
  53.                      GoToXY(1,6);
  54.                      write('Right button pressed  at: ', M^.cx:2, ' ', M^.cy:2);
  55.                   end;
  56.                LEFTBRELEASE:
  57.                   begin
  58.                      GoToXY(1,4);
  59.                      write('Left button released at: ', M^.cx:2, ' ', M^.cy:2);
  60.                   end;
  61.                RIGHTBRELEASE:
  62.                   begin
  63.                      GoToXY(1,6);
  64.                      write('Right button released at: ', M^.cx:2, ' ', M^.cy:2);
  65.                   end;
  66.             end; {case}
  67.             MOUshow;
  68.          end; {if}
  69.  
  70.    until (M^.buttonstat = LEFTBPRESS) AND (M^.cy = 10) AND (M^.cx IN [11..13]);
  71.    MOUdeinit;                        (* de-activate the routines *)
  72.  
  73. end.
  74.  
  75.